REP=$(shell pwd | sed "s%/.*/%%")

CC=gcc
CFLAGS=-g -Wall  `pkg-config --cflags glib-2.0`
LIBS=`pkg-config --libs glib-2.0`

UTILE=sauvegarde.o client.o serveur.o clientserveur.o
SOURCEC=$(wildcard *.c)
OBJC=$(SOURCEC:.c=.o)
EXE=serveur.exe client.exe

all: serveur.exe client.exe

%.o :	%.c %.h
	$(CC) $(CFLAGS) -c $<

%.exe :	%.o	$(UTILE)
	$(CC) $(CFLAGS) main.c $(UTILE) $(LIBS) -o $@

clean :
	@for i in $(OBJC) $(BIN) $(EXE); \
	do \
		if [ -f $$i ]; then \
			echo "efface "$$i;\
			rm $$i; \
		fi; \
	done \

grosclean : clean
	@for i in `ls *~`; \
	do \
		if [ -f $$i ]; then \
			echo "efface "$$i;\
			rm $$i; \
		fi; \
	done

tgz:: clean
	tar czvf ../$(REP)-`date +%y%m%d`.tgz -C ..  --exclude '*~' --exclude Docs --exclude .svn  $(REP)
